package cn.yllr.tomgxianghui.util;

import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Base64;

public class MD5Util {
    /*uuid*/
    private static final String KEY="7f606388-f44c-499d-815c-714a0e66c0ea";
    public static String EncodeByMD5(String str) {
        String newString = "";
        try {
            MessageDigest md5 = MessageDigest.getInstance("MD5");
            str = Base64.getEncoder().encodeToString(md5.digest(str.getBytes(StandardCharsets.UTF_8))) + KEY;
            newString = Base64.getEncoder().encodeToString(md5.digest(str.getBytes(StandardCharsets.UTF_8)));
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        }
        return newString;
    }
}
